﻿

function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}
function limiter(id, lenght) {
    var tex = document.getElementById(id).value;
    var count = lenght;    
    var len = tex.length;
    if (len > count) {
        tex = tex.substring(0, count);
        document.getElementById(id).value = tex;      
        return false;
    }

}
function ShowHideDiv(id, flag) {
    if (flag == "1")
    { document.getElementById('' + id + '').style.display = "block"; }
    else
    { document.getElementById('' + id + '').style.display = "none"; }
}
function toggleDiv(id, flagit) {
    if (flagit == "1") {
        if (document.layers) document.layers['' + id + ''].visibility = "show"
        else if (document.all) document.all['' + id + ''].style.visibility = "visible"
        else if (document.getElementById) document.getElementById('' + id + '').style.visibility = "visible"
    }
    else
        if (flagit == "0") {
            if (document.layers) document.layers['' + id + ''].visibility = "hide"
            else if (document.all) document.all['' + id + ''].style.visibility = "hidden"
            else if (document.getElementById) document.getElementById('' + id + '').style.visibility = "hidden"
        }
}
function trim(stringToTrim) {

    return stringToTrim.replace(/^\s+|\s+$/g, "");

}

function ltrim(stringToTrim) {

    return stringToTrim.replace(/^\s+/, "");

}

function rtrim(stringToTrim) {

    return stringToTrim.replace(/\s+$/, "");

}
function ISNumber(sender, Value) {
    var reg = /^([0-9]{1,3})$/;
    if (reg.test(Value) == false) {
        sender.value = 1;
       
        return false;
    }
    else {
        return true;
    }
}
function StartTime(value) {
    // alert(value);
    var reg = /^([0-9 .:]{1})$/;
    if (reg.test(value) == false)
    { return false; }
    else{return true;}
   
}
function ISChar(Value) {
    var reg = /^([a-zA-Z _]{2,100})$/;
    if (reg.test(Value) == false)
    { return false; }
    else {
        return true;
    }
}

function floatAmount(value) {
    var reg = /^([0-9]{1,3})([.]{1,1})$/;
    if (reg.test(Value) == false) {
        
        return false;
    }
    else {
        return true;
    }
}

function validate(Email) {

    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;


    if (reg.test(Email) == false) {

        return false;
    }
    else {
        return true;
    }
}
function MobileValidate(MobileNo) {
    var reg = /^([7-9]{1})([0-9]{9})$/;
    if (reg.test(MobileNo) == false)
    { return false; }
    else {
        return true;
    }
}
function LandlineValidate(PhoneNo) {
    var reg = /^([1-9]{1})([0-9]{7})$/;
    if (reg.test(PhoneNo) == false)
    { return false; }
    else {
        return true;
    }
}
function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
}


